﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using Microsoft.Practices.Unity.Configuration;
using Microsoft.Practices.Unity;
using Skynet.BusinessLogic.DataAccess;

namespace Skynet.BusinessLogic.TestClient
{
    class Program
    {
        static void Main(string[] args)
        {
            


            //var rep = Container.Resolve<BusinessLogic.DataAccess.IExamCategoryRepository>();

            //System.Threading.Tasks.Parallel.For(1, 20, delegate(int i)
            //{
            //    var reader = rep.GetAllStream();
            //    while (reader.Read())
            //    {
            //        Console.WriteLine(reader[1].ToString());
            //    }
            //    reader.Close(); 
            //});            


            try
            {
                var Container = Infrastructure.Aspect.Patterns.Singleton<UnityContainer,IUnityContainer>.Instance;

                var fileMapPolicies = new ExeConfigurationFileMap { ExeConfigFilename = @".\Config\Aspect.config" };
                var configurationPolicies = ConfigurationManager.OpenMappedExeConfiguration(fileMapPolicies, ConfigurationUserLevel.None);
                var unitySectionPolicies = (UnityConfigurationSection)configurationPolicies.GetSection("unity");
                Container.LoadConfiguration(unitySectionPolicies);

                var fileMapDataAccess = new ExeConfigurationFileMap { ExeConfigFilename =  @".\Config\DataAccess.config"};
                var configurationDataAccess = ConfigurationManager.OpenMappedExeConfiguration(fileMapDataAccess, ConfigurationUserLevel.None);
                var unitySectionDataAccess = (UnityConfigurationSection)configurationDataAccess.GetSection("unity");
                Container.LoadConfiguration(unitySectionDataAccess);

                var test = new BusinessLogic.Test.DataAccess.ExamCategoryTest();
                BusinessLogic.Test.DataAccess.ExamCategoryTest.Container = Container;

                var  reps = new List< IExamCategoryRepository>();
                for (int i = 0; i < 20; i++)
                {
                    var rep = Container.Resolve<BusinessLogic.DataAccess.IExamCategoryRepository>();
                    rep.GetAll();
                    reps.Add(rep);
                }            
                Console.WriteLine("termino");               

            }
            catch (Exception ex)
            {

                Console.WriteLine(ex.Message);  
            }
            



            Console.ReadLine();  
        }
    }
}
